from random import randint
from copy import deepcopy


def myAnd(s1, s2):
    s = MySet()
    for x in s1.list:
        if x in s2.list:
            s.list.append(x)
    return s


def myOr(s1, s2):
    s = MySet(s1)
    for x in s2.list:
        if x not in s.list:
            s.list.append(x)
    return s


def mySub(s1, s2):
    s = MySet()
    for x in s1.list:
        if x not in s2.list:
            s.list.append(x)
    return s


class MySet(object):
    def __init__(self, s=None):
        if s is not None:
            self.list = deepcopy(s.list)
        else:
            self.list = []

    def __str__(self):
        return str(sorted(self.list))

    def add(self, x):
        if x not in self.list:
            self.list.append(x)


def solve():
    s1 = MySet()
    s2 = MySet()
    for i in range(10):
        s1.add(randint(0, 10))
        s2.add(randint(0, 10))
    print(s1)
    print(s2)
    print(myAnd(s1, s2))
    print(myOr(s1, s2))
    print(mySub(s1, s2))


if __name__ == "__main__":
    solve()
